package com.pavco.caribbeanvisit.client.event;

import java.util.ArrayList;

import com.google.gwt.event.shared.GwtEvent;
import com.pavco.caribbeanvisit.shared.models.Country;
import com.pavco.caribbeanvisit.client.eventhandlers.ReceivedCountriesEventHandler;

public class ReceivedCountriesEvent extends GwtEvent<ReceivedCountriesEventHandler> {
  public static final GwtEvent.Type<ReceivedCountriesEventHandler> TYPE =
    new GwtEvent.Type<ReceivedCountriesEventHandler>();
  
  private ArrayList<Country> receivedCountries = new ArrayList<Country>();
  private Throwable error;

  @Override
  protected void dispatch(ReceivedCountriesEventHandler handler) {
    handler.onReceived(this);
  }

  @Override
  public com.google.gwt.event.shared.GwtEvent.Type<ReceivedCountriesEventHandler> getAssociatedType() {
    return TYPE;
  }
  
  public void setCountries(ArrayList<Country> receivedCountries) {
    this.receivedCountries = receivedCountries;
  }
  
  public ArrayList<Country> getCountries() {
    return receivedCountries;
  }
  
  public Throwable getError() {
    return error;
  }

  public void setError(Throwable error) {
    this.error = error;
  }
  
  public boolean isFailed() {
    return (error != null);
  }
}